/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package proms.net.controle;

import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import proms.net.modelo.comando.InterfaceComando;
import proms.net.modelo.helper.PromsHelper;

/**
 *
 * @author Harley
 */
public class PromsControle extends HttpServlet {
    
    private PromsHelper promsHelper = new PromsHelper();
   
   public PromsControle(){
       super();
   }
    @Override
   public void init(ServletConfig config) throws ServletException {
		
		super.init(config);
		
                }
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        
        promsHelper.setRequest(request);
        InterfaceComando comando = promsHelper.getComando();
        String pagina = comando.execute(request, response);
        System.out.println("imprime " +pagina);

        request.getRequestDispatcher(pagina).forward(request, response);
    }
    
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);

    } 

    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
